#include <stdio.h>

int CountDigit(int number, int digit);

int main()
{
    int number, digit;

    scanf("%d %d", &number, &digit);
    printf("Number of digit %d in %d: %d\n", digit, number, CountDigit(number, digit));
    return 0;
}

char *myitoa(int num, char *str)
{
    int i = 0;
    int k = 0;
    if (num < 0)
    {
        str[i++] = '-';
        num = -num;
        k = 1;
    }
    do
    {
        str[i++] = (num % 10) + '0';
        num /= 10;
    } while (num);
    //In this problem,it's no need to reverse the str;
    //You can delete the code below,and the answer  is still right.
    // Use this code,if you meet the problem that integer need to be transformed to string.
    //If num < 0,index start from 0 on reversing;else num > 0,index start from 1;This is the use of k.
    char temp;
    //012345
    //j     i
    for (int j = k; j <= (i - 1) / 2; j++)
    {
        temp = str[j];
        str[j] = str[i - j + k - 1];
        str[i - j - 1 + k] = temp; // index need -1 ,because i == len(str)
    }
}

int CountDigit(int number, int digit)
{
    char str[64] = {0};
    myitoa(number, str);

    int i = 0, count = 0;

    while (str[i] != '\0')
    {
        if (str[i++] - '0' == digit)
            count++;
    }

    return count;
}